{extends file="./main.tpl"}
{block name=head}
<script type="text/javascript">
$(document).ready(function(){
 });
function getProcessData(theId){
  var dataString = "planningId=" + theId;
	$.ajax({
		type: "POST",
		url: "getProcess.php",
		data: dataString,
		dataType: 'json',
		success:function(data)
		{
			$(".pIncomingId").empty();
			$(".pPartyId").empty();
			$(".oldQuantity").empty();
			$(".quantity").empty();
			$(".oldWeight").empty();
			$(".weight").empty();
			$(".process1Id").empty();
			$(".process2Id").empty();
			$(".process3Id").empty();

			$(".temp1").empty();
			$(".soaking1").empty();
			$(".furnace1").fadeOut();
			$(".temp2").empty();
			$(".soaking2").empty();
			$(".furnace2").fadeOut();
			$(".temp3").empty();
			$(".soaking3").empty();
			$(".furnace3").fadeOut();
			
			if(data[0].process1 == 1)
			{
				$(".temp1").append('<input type=text size="8" name="temp1" id="temp1" />');
				$(".soaking1").append('<input type=text size="8" name="soaking1" id="soaking1" />');
				$(".furnace1").fadeIn();
				
        if(data[0].processId2 > 0)
        {
				  $(".temp2").append('<input type=text size="8" name="temp2" id="temp2" AUTOFOCUS />');
				  $(".soaking2").append('<input type=text size="8" name="soaking2" id="soaking2" />');
				  $(".furnace2").fadeIn();
				}
			}
			else
			{
				$(".temp1").append('<input type=text size="8" name="temp1" id="temp1" AUTOFOCUS />');
				$(".soaking1").append('<input type=text size="8" name="soaking1" id="soaking1" />');
				$(".furnace1").fadeIn();
			}
						
			if(data[0].process2 == 1)
			{
				$(".temp2").empty();
				$(".soaking2").empty();
				//$(".furnace2").empty();
				
				$(".temp2").append('<input type=text size="8" name="temp2" id="temp2" />');
				$(".soaking2").append('<input type=text size="8" name="soaking2" id="soaking2" />');
				$(".furnace2").fadeIn();
				
				if(data[0].processId3 > 0)
        {
        	$(".temp3").append('<input type=text size="8" name="temp3" id="temp3" AUTOFOCUS />');
				  $(".soaking3").append('<input type=text size="8" name="soaking3" id="soaking3" />');
				  $(".furnace3").fadeIn();
				}
			}

			
			if(data[0].process3 == 1)
			{
				$(".temp2").empty();
				$(".soaking2").empty();
				//$(".furnace2").empty();
				$(".temp3").empty();
				$(".soaking3").empty();
				//$(".furnace3").empty();

				$(".temp2").append('<input type=text size="8" name="temp2" id="temp2" />');
				$(".soaking2").append('<input type=text size="8" name="soaking2" id="soaking2" />');
				$(".furnace2").fadeIn();

				$(".temp3").append('<input type=text size="8" name="temp3" id="temp3" />');
				$(".soaking3").append('<input type=text size="8" name="soaking3" id="soaking3" />');
				$(".furnace3").fadeIn();
			}            
			
      $(".pIncomingId").append('<input type="hidden" name="pIncomingId" id="pIncomingId" />');
      $(".pPartyId").append('<input type="hidden" name="pPartyId" id="pPartyId" />');
			$(".quantity").append('<input type="hidden" name="oldQuantity" id="oldQuantity" /><input type=text size="8" name="plannedQuantity" id="plannedQuantity" required="required" />');
			$(".weight").append('<input type="hidden" name="oldWeight" id="oldWeight" /><input type=text size="8" name="plannedWeight" id="plannedWeight" required="required" />');
      $(".process1Id").append('<input type="hidden" name="process1Id" id="process1Id" />');
      $(".process2Id").append('<input type="hidden" name="process2Id" id="process2Id" />');
      $(".process3Id").append('<input type="hidden" name="process3Id" id="process3Id" />');
      
			$("#pIncomingId").val(data[0].incomingId);
			$("#pPartyId").val(data[0].partyId);
			$("#oldQuantity").val(data[0].quantity);
			$("#plannedQuantity").val(data[0].quantity);
			$("#oldWeight").val(data[0].weight);
			$("#plannedWeight").val(data[0].weight);
			$("#process1Id").val(data[0].processId1);
			$("#process2Id").val(data[0].processId2);
			$("#process3Id").val(data[0].processId3);


			$("#temp1").val(data[0].temp1);
			$("#soaking1").val(data[0].soaking1);
			$("#furnace1").val(data[0].furnace1);
			
			$("#temp2").val(data[0].temp2);
			$("#soaking2").val(data[0].soaking2);
			$("#furnace2").val(data[0].furnace2);
			
			$("#temp3").val(data[0].temp3);
			$("#soaking3").val(data[0].soaking3);
			$("#furnace3").val(data[0].furnace3);


		  var ajaxString = "planningId=" + theId + "&notOkData=1";
			$.ajax({
				type: "POST",
				url: "getProcess.php",
				data: ajaxString,
				success:function(data)
				{
					$('#notOkSpan').html(data);
				}
			});
			
		}
	});
}
function myFunction()
{
	if(confirm("You Want To Remove This Record")== true)
	{
		return true;
	}
	else
	{
		return false;
	}
}
</script>
{/block}
{block name=body}
<form name="form1" id="form1" action="{$smarty.server.PHP_SELF}" method="post" onsubmit="return confirm('DO You Want To Submit !!!!!')";>
<input type="hidden" name="incomingId" size="5">
<table border="0" align="center" width="100%">
<tr>
	<td width="80%" valign="top">
  <table border="0" align="left" width="100%">
  <tr>
    <td colspan="6" align="right" ><font size="3"><b>Planing List</b></font></td>
  </tr>
  <tr><td>&nbsp;</td></tr>
  <tr>
    <td colspan="5"  align="right" class="table1"><font size="3"><b>Party</b></font></td>
    <td colspan="10" class="table1">                                                               
    <select name="partyId" id="partyId" onchange="this.form.submit();" >
    <option value="" >All</option>
    {html_options values=$catTitleArray.partyId output=$catTitleArray.partyName selected=$partyId}
    </select>
    </td>
  </tr>
  <tr align="center" class="table1">
    <td>Temperature1</td>
    <td>Soaking1</td>
    <td>Furnace1</td>
    <td>Temperature2</td>
    <td>Soaking2</td>
    <td>Furnace2</td>
    <td>Temperature3</td>
    <td>Soaking3</td>
    <td>Furnace3</td>
    <td>Quantity</td>
    <td>Weight</td>
  </tr>
  <tr align="center" class="table2">
  	<span class="pIncomingId"></span>
  	<span class="pPartyId"></span>
  	<span class="process1Id"></span>
  	<span class="process2Id"></span>
  	<span class="process3Id"></span>
    <td>&nbsp;<span class="temp1"></span></td>
    <td><span class="soaking1"></span></td>
    <td>
    	<span class="furnace1" style="display:none;">
    	<select name="furnace1" AUTOFOCUS id="furnace1">
				<option value="">Select</option>
				{html_options values=$furnaceArray.fId output=$furnaceArray.furnaceName}
		  </select>
    	</span>
    </td>
    <td><span class="temp2"></span></td>
    <td><span class="soaking2"></span></td>
    <td>
    	<span class="furnace2" style="display:none;">
    	<select name="furnace2" id="furnace2">
				<option value="">Select</option>
				{html_options values=$furnaceArray.fId output=$furnaceArray.furnaceName}
		  </select>
    	</span>
    </td>

    <td><span class="temp3"></span></td>
    <td><span class="soaking3"></span></td>
    <td>
    	<span class="furnace3" style="display:none;">
    	<select name="furnace3" id="furnace3">
				<option value="">Select</option>
				{html_options values=$furnaceArray.fId output=$furnaceArray.furnaceName}
		  </select>
    	</span>
    </td>

    <td><span class="quantity"></span></td>
    <td><span class="weight"></span></td>
  </tr>
  <tr><td class="table1" colspan="11" align="center"><input type="submit" name="submitbtn" value=" Submit "></td></tr>
  <tr>
    <td class="table1" align='center' ><B>Select</B></td>
    <td class="table1" align='center' ><B>Party</B></td>
    <td class="table1" align='center' ><B>Date</B></td>
    <td class="table1" align='center' ><B>Challan</B></td>
    <td class="table1" align='center' ><B>Quantity</B></td>
    <td class="table1" align='center' ><B>Weight</B></td>
    <td class="table1" align='center' ><B>Material</B></td>
    <td class="table1" align='center' ><B>Hardne</B></td>
    <td class="table1" align='center' ><B>Process1</B></td>
    <td class="table1" align='center' ><B>Process2</B></td>
    <td class="table1" align='center' ><B>Process3</B></td>
  </tr>
   {section name="sec" loop=$incomingRegister}
  <tr>
    <td class="table2" align='center'><input type="radio"  name="planningId" value="{$incomingRegister[sec].planningId}" onclick="getProcessData({$incomingRegister[sec].planningId});" /></td>
    <td class="table2" align="left" NOWRAP>{$incomingRegister[sec].partyName}</td>
    <td class="table2" align="left" NOWRAP>{$incomingRegister[sec].IncomingDate}</td>
    <td class="table2" align="center">{$incomingRegister[sec].challan}</td>
    <td class="table2" align="center">{$incomingRegister[sec].qty}</td>
    <td class="table2" align="center">{$incomingRegister[sec].weight}</td>
    <td class="table2" align="center" NOWRAP>{$incomingRegister[sec].material}</td>
    <td class="table2" align="center" NOWRAP>{$incomingRegister[sec].hardne}</td>
    <td class="table2" align="left" NOWRAP>{$incomingRegister[sec].processName1}</td>
    <td class="table2" align="left" NOWRAP>{$incomingRegister[sec].processName2}</td>
    <td class="table2" align="left" NOWRAP>{$incomingRegister[sec].processName3}</td>
  </tr>
  {sectionelse}
  <tr>
    <td colspan="11" align="center">
      {$msg}
    </td>
  </tr> 
  {/section}
  </table>
  </td>
  <td valign="top">
  	<span id="notOkSpan"></span>
  </td>
</tr>
</table>
{/block}